package com.xindaoapp.happypet.adapter;

import java.util.List;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.nostra13.universalimageloader.core.ImageLoader;
import com.xindaoapp.happypet.R;
import com.xindaoapp.happypet.bean.Post;
import com.xindaoapp.happypet.fragments.UserInfoFragment;
import com.xindaoapp.happypet.ui.PostDetailImgsActivity;
import com.xindaoapp.happypet.ui.ZanListActivity;
import com.xindaoapp.happypet.utils.BitmapUtil;
import com.xindaoapp.happypet.utils.CommonParameter;
import com.xindaoapp.happypet.utils.CommonUtil;
import com.xindaoapp.happypet.utils.Constants;
import com.xindaoapp.happypet.view.CircleImageView;

/**
 * 帖子列表Adapter
 * 
 * @author
 * 
 */
public class MyPostListAdapter extends MyBaseAdapter<Post> {
    private final Context mContext;
    private final List<Post> mList;
    private final int currentIndex;
    private final int photoSize = 120;
    private final int displayWidth = 720;


    public MyPostListAdapter(Context context, List<Post> mList, int resId, int currentIndex) {
        super(context, mList, resId);
        this.mContext = context;
        this.mList = mList;
        this.currentIndex = currentIndex;
    }

    public void addData(List<Post> mList) {
        this.mList.addAll(mList);
        notifyDataSetChanged();
    }

    public void clearData(List<Post> mList) {
        this.mList.clear();
        // notifyDataSetChanged();
    }

    private int getWidth() {

        WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
        return wm.getDefaultDisplay().getWidth();
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent, Post t) {
        ViewHolder holder = (ViewHolder) convertView.getTag();
        final Post post = mList.get(position);
        if (holder == null) {
            holder = new ViewHolder();
            holder.line = convertView.findViewById(R.id.line);
            holder.layout_imgs = (LinearLayout) convertView.findViewById(R.id.layout_imgs);
            holder.lay_zan = (RelativeLayout) convertView.findViewById(R.id.lay_zan);
            holder.layout_gozan = (RelativeLayout) convertView.findViewById(R.id.layout_gozan);
            holder.layout_gohuifu = (RelativeLayout) convertView.findViewById(R.id.layout_gohuifu);
            holder.iv_icon = (CircleImageView) convertView.findViewById(R.id.iv_icon);
            holder.iv_zan = (ImageView) convertView.findViewById(R.id.iv_zan);
            holder.iv_jing = (ImageView) convertView.findViewById(R.id.iv_jing);
            holder.tv_name = (TextView) convertView.findViewById(R.id.tv_name);
            holder.tv_time = (TextView) convertView.findViewById(R.id.tv_time);
            holder.tv_title = (TextView) convertView.findViewById(R.id.tv_title);
            holder.tv_content = (TextView) convertView.findViewById(R.id.tv_content);
            holder.tv_position = (TextView) convertView.findViewById(R.id.tv_position);
            holder.tv_zancount = (TextView) convertView.findViewById(R.id.tv_zancount);
            holder.tv_viewcount = (TextView) convertView.findViewById(R.id.tv_viewcount);
            holder.tv_huifucount = (TextView) convertView.findViewById(R.id.tv_huifucount);
            holder.tv_zanname1 = (TextView) convertView.findViewById(R.id.tv_zanname1);
            holder.tv_zanname2 = (TextView) convertView.findViewById(R.id.tv_zanname2);
            holder.tv_zanguo = (TextView) convertView.findViewById(R.id.tv_zanguo);
            convertView.setTag(holder);
        }

        if (Integer.parseInt(post.recommend_add) > 0) {
            holder.tv_zancount.setText(post.recommend_add);
        } else {
            holder.tv_zancount.setText("赞");
        }
        // if (Integer.parseInt(post.replies) > 0) {
        holder.tv_huifucount.setText(post.replies);
        holder.tv_viewcount.setText(post.views);
        // } else {
        // holder.tv_huifucount.setText("回复");
        // }

        ImageLoader.getInstance().displayImage(post.userface, holder.iv_icon,
                BitmapUtil.getPersonLoading());

        holder.tv_name.setText(post.author);
        holder.tv_time.setText(CommonUtil.formatTimeForListCommon(post.updatetime));

        if (!post.subject.equals("")) {
            holder.tv_title.setVisibility(View.VISIBLE);
            holder.tv_title.setText(CommonUtil.convetToHtml(CommonUtil.parseEmoji(post.subject),
                    mContext));
        } else {
            holder.tv_title.setVisibility(View.GONE);
        }

        if (!post.message.equals("")) {
            holder.tv_content.setVisibility(View.VISIBLE);
            holder.tv_content.setText(CommonUtil.convetToHtml(CommonUtil.parseEmoji(post.message),
                    mContext));
        } else {
            holder.tv_content.setVisibility(View.GONE);
        }

        if (Integer.parseInt(post.digest) > 0) {
            holder.iv_jing.setVisibility(View.VISIBLE);
        } else {
            holder.iv_jing.setVisibility(View.GONE);
        }

        if (post.recommendmy.equals("1")) {

            holder.iv_zan.setImageResource(R.drawable.icon_hand_frs_click);
        } else {

            holder.iv_zan.setImageResource(R.drawable.icon_hand_frs_normal);
        }

        if (post.forumname != null && post.forumname.length() != 0) {
            holder.tv_position.setText(post.forumname);
        }

        if (post.recommendarray.size() > 0) {
            holder.line.setVisibility(View.VISIBLE);
            holder.lay_zan.setVisibility(View.VISIBLE);
            if (post.recommendarray.size() >= 2) {
                holder.tv_zanname1.setText(post.recommendarray.get(0).username + "、");
                holder.tv_zanname2.setText(post.recommendarray.get(1).username);
                holder.tv_zanguo.setText("等" + post.recommendtotal + "人赞过");
            } else {
                holder.tv_zanname1.setText(post.recommendarray.get(0).username);
                holder.tv_zanname2.setText("");
                holder.tv_zanguo.setText("赞过");
            }
        } else {
            holder.line.setVisibility(View.GONE);
            holder.lay_zan.setVisibility(View.GONE);
        }


        // 视频或者图片
        if (holder.layout_imgs != null) {
            holder.layout_imgs.removeAllViews();
        }
        holder.layout_imgs.setVisibility(View.GONE);
        if (post.isvideo != null && post.isvideo.equals("1")) {
            holder.layout_imgs.setVisibility(View.VISIBLE);
            View sView = View.inflate(mContext, R.layout.image_pet_icon_shipinzuixin, null);
            ImageView iv = (ImageView) sView.findViewById(R.id.pet_icon);
            android.view.ViewGroup.LayoutParams lp1 = iv.getLayoutParams();
            TextView community_title = (TextView) sView.findViewById(R.id.community_title);
            lp1.width = (CommonParameter.sScreenWidth - CommonUtil.dp2px(mContext, 46.2f)) / 3;
            lp1.height = (CommonParameter.sScreenWidth - CommonUtil.dp2px(mContext, 46.2f)) / 3;
            iv.setScaleType(ScaleType.CENTER_CROP);
            iv.setLayoutParams(lp1);

            if (CommonParameter.isLoadImg) {
                ImageLoader.getInstance().displayImage(post.videocover, iv);
            } else {
                iv.setImageResource(R.drawable.picture_loading);
            }
            // community_title.setVisibility(View.VISIBLE);
            // community_title.setText(ParseMsgUtil.convetToHtml(CommonUtil.parseEmoji(post.subject),
            // mContext));
            LayoutParams lp =
                    new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
            sView.setLayoutParams(lp);
            holder.layout_imgs.addView(sView);
        } else if (post.isvideo == null || post.isvideo.equals("0")) {
            if (post.pics.size() > 0) {
                holder.layout_imgs.setVisibility(View.VISIBLE);
            }
            for (int i = 0; i < post.pics.size(); i++) {
                final int j = i;
                LinearLayout view1 =
                        (LinearLayout) View.inflate(mContext, R.layout.image_pet_icon_zuixin, null);
                LinearLayout layout_count =
                        (LinearLayout) view1.findViewById(R.id.layout_for_count);
                TextView tv_mycount = (TextView) view1.findViewById(R.id.tv_mycount);

                ImageView iv1 = (ImageView) view1.findViewById(R.id.pet_icon);
                android.view.ViewGroup.LayoutParams lp2 = iv1.getLayoutParams();

                lp2.width = (CommonParameter.sScreenWidth - CommonUtil.dp2px(mContext, 46.2f)) / 3;
                lp2.height = (CommonParameter.sScreenWidth - CommonUtil.dp2px(mContext, 46.2f)) / 3;
                iv1.setScaleType(ScaleType.CENTER_CROP);
                iv1.setLayoutParams(lp2);
                if (CommonParameter.isLoadImg) {
                    ImageLoader.getInstance().displayImage(post.pics.get(i).url, iv1);
                } else {
                    iv1.setImageResource(R.drawable.picture_loading);
                }
                LayoutParams lp3 =
                        new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

                if (i == 2 && Integer.parseInt(post.picnum) > 3) {
                    tv_mycount.setText("共" + post.picnum + "张");
                    layout_count.setVisibility(View.VISIBLE);
                }


                if (i > 0) {
                    lp3.leftMargin = CommonUtil.dip2px(mContext, 5);
                }

                view1.setLayoutParams(lp3);

                view1.setOnClickListener(new OnClickListener() {

                    @Override
                    public void onClick(View arg0) {
                        // TODO 到图片集
                        skipToImgs(post.pics.get(j).aid, post.tid);
                    }


                });
                holder.layout_imgs.addView(view1);

            }
        }



        final OnClickListener itemClickListener = new OnClickListener() {
            @Override
            public void onClick(View view) {
                // TODO Auto-generated method stub
                switch (view.getId()) {
                    case R.id.iv_icon:
                    case R.id.tv_name:
                    case R.id.tv_time:
                        // 进入他人中心
                        goOthersCenter(post.authorid, post.author, post.userface);
                        break;

                    case R.id.tv_zanname1:
                        // 进入该人中心
                        if (post.recommendarray != null && post.recommendarray.size() > 0) {
                            goOthersCenter(post.recommendarray.get(0).recommenduid,
                                    post.recommendarray.get(0).username,
                                    post.recommendarray.get(0).userface);
                        }
                        break;
                    case R.id.tv_zanname2:
                        // 进入该人中心
                        if (post.recommendarray != null && post.recommendarray.size() > 1) {
                            goOthersCenter(post.recommendarray.get(1).recommenduid,
                                    post.recommendarray.get(1).username,
                                    post.recommendarray.get(1).userface);
                        }
                        break;



                    case R.id.lay_zan:
                        // 进入点赞列表
                        Intent i = new Intent(mContext, ZanListActivity.class);
                        i.putExtra("title", post.subject);
                        i.putExtra("tid", post.tid);
                        i.putExtra("totalzan", Integer.parseInt(post.recommend_add));
                        mContext.startActivity(i);
                        break;

                    default:
                        break;
                }

            }



            private void goOthersCenter(String uid, String name, String userface) {
                // TODO Auto-generated method stub
                // 进入他人中心
                Intent intent =
                        new Intent(mContext, com.xindaoapp.happypet.activity.MainActivity.class);
                intent.putExtra(Constants.KEY_SKIP_CLASS_NAME,
                        UserInfoFragment.class.getCanonicalName());
                Bundle bundle = new Bundle();
                bundle.putString(Constants.KEY_UID, uid);
                bundle.putString(Constants.KEY_USERNAME, name);
                bundle.putString(Constants.KEY_USERFACE, userface);
                intent.putExtra(Constants.KEY_BUNDLE, bundle);
                mContext.startActivity(intent);
            }
        };

        OnClickListener videoClickListener = new OnClickListener() {

            @Override
            public void onClick(View arg0) {
                // TODO 处理视频点击
                Toast.makeText(mContext, "进入视频 !", Toast.LENGTH_SHORT).show();
            }
        };
        // 进入赞列表
        holder.lay_zan.setOnClickListener(itemClickListener);
        // 进入个人中心
        holder.iv_icon.setOnClickListener(itemClickListener);
        holder.tv_name.setOnClickListener(itemClickListener);
        holder.tv_time.setOnClickListener(itemClickListener);

        convertView.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent =
                        new Intent(mContext, com.xindaoapp.happypet.ui.PostDetailActivity.class);
                intent.putExtra(Constants.KEY_POST_TID, post.tid);
                mContext.startActivity(intent);
            }
        });

        return convertView;
    }

    private void skipToImgs(String aid, String tid) {
        // TODO Auto-generated method stub
        Intent intent = new Intent(mContext, PostDetailImgsActivity.class);
        intent.putExtra(Constants.PARAM_PHOTO_POSITION, aid);
        intent.putExtra(Constants.KEY_POST_TID, tid);
        mContext.startActivity(intent);
    }

    // @Override
    // public View getView(int position, View contentView, ViewGroup parent, Post t) {
    // ViewHolder holder = (ViewHolder) contentView.getTag();
    // final Post post = mList.get(position);
    //
    // if (null == holder) {
    // holder = new ViewHolder();
    // holder.ll = (LinearLayout) contentView.findViewById(R.id.ll_pet_icon);
    // holder.usericon = (CircleImageView) contentView.findViewById(R.id.user_icon);
    // holder.username = (TextView) contentView.findViewById(R.id.user_name);
    // holder.title = (TextView) contentView.findViewById(R.id.tv_title);
    // holder.type = (ImageView) contentView.findViewById(R.id.iv_top_right);
    // holder.look = (TextView) contentView.findViewById(R.id.look_time);
    // // holder.care = (TextView) contentView.findViewById(R.id.care_time);
    // holder.message = (TextView) contentView.findViewById(R.id.message_time);
    // holder.time = (TextView) contentView.findViewById(R.id.time);
    // contentView.setTag(holder);
    // }
    // holder.title.setVisibility(View.VISIBLE);
    // holder.ll.removeAllViews();
    //
    // displayWidth = getWidth();
    // if (displayWidth < 720) {
    // photoSize = 64;
    // }
    //
    // int j = 0;
    // if (currentIndex == 4) {
    // j = 1;
    // } else {
    // j = post.getPics().size();
    // }
    // if (post.getIsvideo() != null && post.getIsvideo().equals("1")) {
    //
    // // RelativeLayout.LayoutParams lp1 =
    // // new RelativeLayout.LayoutParams(CommonUtil.dip2px(mContext, 300),
    // // CommonUtil.dip2px(mContext, 300));
    // View sView = View.inflate(mContext, R.layout.image_pet_icon_shipin, null);
    // ImageView iv = (ImageView) sView.findViewById(R.id.pet_icon);
    // android.view.ViewGroup.LayoutParams lp1 = iv.getLayoutParams();
    // TextView community_title = (TextView) sView.findViewById(R.id.community_title);
    // lp1.width = (CommonParameter.sScreenWidth - CommonUtil.dp2px(mContext, 70)) / 3;
    // lp1.height = (CommonParameter.sScreenWidth - CommonUtil.dp2px(mContext, 70)) / 3;
    // iv.setLayoutParams(lp1);
    // // iv.setScaleType(ImageView.ScaleType.CENTER_CROP);
    //
    // if (CommonParameter.isLoadImg) {
    // ImageLoader.getInstance().displayImage(post.getVideocover(), iv);
    // } else {
    // iv.setImageResource(R.drawable.picture_loading);
    // }
    // // LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT,
    // // LayoutParams.WRAP_CONTENT);
    // holder.title.setVisibility(View.GONE);
    // community_title.setVisibility(View.VISIBLE);
    // community_title.setText(ParseMsgUtil.convetToHtml(
    // CommonUtil.parseEmoji(post.getSubject()), mContext));
    // LayoutParams lp =
    // new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    // sView.setLayoutParams(lp);
    // holder.ll.addView(sView);
    // } else if (post.getIsvideo() == null || post.getIsvideo().equals("0")) {
    // switch (j) {
    // case 0:
    //
    // break;
    // case 1:
    // // RelativeLayout.LayoutParams lp1 =
    // // new RelativeLayout.LayoutParams(CommonUtil.dip2px(mContext, 300),
    // // CommonUtil.dip2px(mContext, 300));
    // if (currentIndex == 4) {// 说明是视频列表
    // View sView = View.inflate(mContext, R.layout.image_pet_icon_shipin, null);
    // ImageView iv = (ImageView) sView.findViewById(R.id.pet_icon);
    // android.view.ViewGroup.LayoutParams lp1 = iv.getLayoutParams();
    // TextView community_title =
    // (TextView) sView.findViewById(R.id.community_title);
    // lp1.width =
    // (CommonParameter.sScreenWidth - CommonUtil.dp2px(mContext, 70)) / 3;
    // lp1.height =
    // (CommonParameter.sScreenWidth - CommonUtil.dp2px(mContext, 70)) / 3;
    // iv.setLayoutParams(lp1);
    // // iv.setScaleType(ImageView.ScaleType.CENTER_CROP);
    //
    // if (CommonParameter.isLoadImg) {
    // ImageLoader.getInstance().displayImage(post.getVideocover(), iv);
    // } else {
    // iv.setImageResource(R.drawable.picture_loading);
    // }
    // holder.title.setVisibility(View.GONE);
    // community_title.setVisibility(View.VISIBLE);
    // community_title.setText(ParseMsgUtil.convetToHtml(
    // CommonUtil.parseEmoji(post.getSubject()), mContext));
    // LayoutParams lp =
    // new LayoutParams(LayoutParams.WRAP_CONTENT,
    // LayoutParams.WRAP_CONTENT);
    // sView.setLayoutParams(lp);
    // holder.ll.addView(sView);
    // } else {
    // View view = View.inflate(mContext, R.layout.image_pet_icon, null);
    // ImageView iv = (ImageView) view.findViewById(R.id.pet_icon);
    // TextView community_title =
    // (TextView) view.findViewById(R.id.community_title);
    // android.view.ViewGroup.LayoutParams layoutParams = iv.getLayoutParams();
    // layoutParams.height =
    // (CommonParameter.sScreenWidth - CommonUtil.dp2px(mContext, 70)) / 3;
    // layoutParams.width =
    // (CommonParameter.sScreenWidth - CommonUtil.dp2px(mContext, 70)) / 3;
    // // LinearLayout.LayoutParams lp3 =
    // // new LinearLayout.LayoutParams(CommonParameter.sScreenWidth / 3,
    // // CommonParameter.sScreenWidth / 3, 3);
    // iv.setLayoutParams(layoutParams);
    // // iv.setScaleType(ImageView.ScaleType.CENTER_CROP);
    //
    // if (CommonParameter.isLoadImg) {
    // ImageLoader.getInstance().displayImage(post.getPics().get(0).getUrl(),
    // iv);
    // } else {
    // iv.setImageResource(R.drawable.picture_loading);
    // }
    // holder.title.setVisibility(View.GONE);
    // community_title.setVisibility(View.VISIBLE);
    // community_title.setText(ParseMsgUtil.convetToHtml(
    // CommonUtil.parseEmoji(post.getSubject()), mContext));
    //
    // LayoutParams lp =
    // new LayoutParams(LayoutParams.WRAP_CONTENT,
    // LayoutParams.WRAP_CONTENT);
    // view.setLayoutParams(lp);
    // holder.ll.addView(view);
    // }
    // break;
    // case 2:
    // case 3:
    // for (int i = 0; i < post.getPics().size(); i++) {
    // LinearLayout view1 =
    // (LinearLayout) View
    // .inflate(mContext, R.layout.image_pet_icon, null);
    // ImageView iv1 = (ImageView) view1.findViewById(R.id.pet_icon);
    // TextView community_title =
    // (TextView) view1.findViewById(R.id.community_title);
    // android.view.ViewGroup.LayoutParams lp2 = iv1.getLayoutParams();
    //
    // lp2.width =
    // (CommonParameter.sScreenWidth - CommonUtil.dp2px(mContext, 70)) / 3;
    // lp2.height =
    // (CommonParameter.sScreenWidth - CommonUtil.dp2px(mContext, 70)) / 3;
    // // LinearLayout.LayoutParams lp2 =
    // // new LinearLayout.LayoutParams(CommonParameter.sScreenWidth / 3,
    // // CommonParameter.sScreenWidth / 3, 3);
    // iv1.setLayoutParams(lp2);
    // // iv1.setScaleType(ImageView.ScaleType.CENTER_CROP);
    // if (CommonParameter.isLoadImg) {
    // ImageLoader.getInstance().displayImage(post.getPics().get(i).getUrl(),
    // iv1);
    // } else {
    // iv1.setImageResource(R.drawable.picture_loading);
    // }
    // LayoutParams lp3 =
    // new LayoutParams(LayoutParams.WRAP_CONTENT,
    // LayoutParams.WRAP_CONTENT);
    // if (post.getPics().size() == 1) {
    // holder.title.setVisibility(View.GONE);
    // community_title.setVisibility(View.VISIBLE);
    // community_title.setText(ParseMsgUtil.convetToHtml(
    // CommonUtil.parseEmoji(post.getSubject()), mContext));
    //
    // }
    // if (i > 0) {
    // lp3.leftMargin = CommonUtil.dip2px(mContext, 5);
    // }
    //
    // view1.setLayoutParams(lp3);
    // holder.ll.addView(view1);
    // }
    // break;
    //
    // default:
    // break;
    // }
    // }
    // if (CommonParameter.isLoadImg) {
    // ImageLoader.getInstance().displayImage(post.getUserface(), holder.usericon,
    // BitmapUtil.getPersonLoading());
    // } else {
    // holder.usericon.setImageResource(R.drawable.person_loading);
    // }
    // holder.username.setText(post.getAuthor());
    //
    // holder.title.setText(ParseMsgUtil.convetToHtml(CommonUtil.parseEmoji(post.getSubject()),
    // mContext));
    //
    // holder.look.setText(post.getViews() + "访问");
    // // holder.care.setText(post.getRecommend_add());
    // holder.message.setText(post.getReplies() + "参与");
    //
    // String time = CommonUtil.formatDate();
    // String year = time.substring(0, 4);
    // String hour = time.split(" ")[1].split(":")[0];
    // String min = time.split(" ")[1].split(":")[1];
    //
    // String mTime = null;
    // if (currentIndex == 1) {
    // mTime = post.getUpdatetime();
    // } else {
    // mTime = post.getAddtime();
    // }
    // String mYear = mTime.substring(0, 4);
    // String mMonth = mTime.split(" ")[0].split("-")[1];
    // String mDay = mTime.split(" ")[0].split("-")[2];
    // String mHour = mTime.split(" ")[1].split(":")[0];
    // String mMin = mTime.split(" ")[1].split(":")[1];
    //
    // if (year.equals(mYear)) {// 说明是今年
    // if (mTime.split(" ")[0].equals(time.split(" ")[0])) {// 说明是今天
    // holder.time.setText(mHour + ":" + mMin);
    // } else {
    // holder.time.setText(mMonth + "-" + mDay);
    // }
    // } else {
    // holder.time.setText(mTime.split(" ")[0]);
    // }
    //
    // switch (currentIndex) {
    // case 1:
    // if (Integer.parseInt(post.getDigest()) > 0) {// 精华
    // holder.type.setBackgroundResource(R.drawable.jing);
    // } else {
    // holder.type.setBackgroundColor(Color.WHITE);
    // }
    //
    // if (Integer.parseInt(post.getDisplayorder()) > 0) { // 置顶
    // // holder.type.setBackgroundResource(R.drawable.ding);
    // } else {
    // holder.type.setBackgroundColor(Color.WHITE);
    // }
    // // else if (Integer.parseInt(post.getDigest()) == 0) {
    // // holder.type.setBackgroundResource(R.drawable.new1);
    // // }
    // break;
    // case 2:// 精华
    // // holder.type.setBackgroundResource(R.drawable.jing);
    // break;
    // case 3:// 最新
    // // holder.type.setBackgroundResource(R.drawable.new1);
    // break;
    // case 4:// 视频
    // // holder.type.setBackgroundResource(R.drawable.shi);
    // break;
    // default:
    // break;
    // }
    //
    // contentView.setOnClickListener(new OnClickListener() {
    // @Override
    // public void onClick(View arg0) {
    // Intent intent = new Intent(mContext, PostDetailActivity.class);
    // intent.putExtra(Constants.KEY_POST_TID, post.getTid());
    // intent.putExtra(Constants.KEY_FROM_PAGE, 1);
    // mContext.startActivity(intent);
    // }
    // });
    // return contentView;
    // }
    // class ViewHolder {
    // LinearLayout ll;
    // CircleImageView usericon;
    // TextView username;
    // TextView title;
    // ImageView type;
    // TextView look;
    // // TextView care;
    // TextView message;
    // TextView time;
    // TextView community_title;
    // }
    class ViewHolder {
        View line;
        LinearLayout layout_imgs;
        RelativeLayout lay_zan, layout_gozan, layout_gohuifu;
        CircleImageView iv_icon;
        ImageView iv_zan, iv_huifu, iv_jing;
        TextView tv_name, tv_time, tv_title, tv_content, tv_position, tv_zancount, tv_huifucount,
                tv_zanname1, tv_viewcount, tv_zanname2, tv_zanguo;
    }
}
